package com.itheima.servlet;


import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/demo1")
public class Demo01 extends HttpServlet {


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp){
        String str = "你好";
        try {
            //req.setCharacterEncoding("UTF-8");
            resp.setContentType("text/html;charset=UTF-8");
            ServletOutputStream os = resp.getOutputStream();
            os.write(str.getBytes("UTF-8"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
